package com.adcc.loadsheet.monitor.vo;

import com.adcc.loadsheet.monitor.entity.AppUploadMonitor;
import com.adcc.loadsheet.monitor.entity.MonitorStatus;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.google.common.base.Strings;

public class AppUploadMonitorVO extends BaseVO<AppUploadMonitor> {

    // 远程时间（运行程序的本地时间）
    private String remoteDateTime;

    // 本地时间（本地进行NTP授时，即NTP时间）
    private String localDateTime;

    // 时间分钟差
    private String minutesBetween;

    // NTP状态
    private boolean ntpStatus;

    // 舱单接收总数
    private long receiveCount;

    // 舱单拆分失败数
    private long failCount;

    // 最新报文接收时间
    private String lastRecvTime;

    // 舱单拆分失败率
    private double failureRate;

    // 舱单拆分服务状态
    private boolean loadsheetStatus;

    // 服务状态
    private MonitorStatus status;

    public AppUploadMonitorVO() {

    }

    public AppUploadMonitorVO(AppUploadMonitor appUploadMonitor) {
        remoteDateTime = Strings.nullToEmpty(appUploadMonitor.getRemoteDateTime());
        localDateTime = Strings.nullToEmpty(appUploadMonitor.getLocalDateTime());
        if(appUploadMonitor.getMinutesBetween() >= 0) {
            minutesBetween = "+" + Math.abs(appUploadMonitor.getMinutesBetween());
        } else {
            minutesBetween = "-" + Math.abs(appUploadMonitor.getMinutesBetween());
        }
        ntpStatus = appUploadMonitor.isNtpStatus();
        receiveCount = appUploadMonitor.getReceiveCount();
        failCount = appUploadMonitor.getFailCount();
        lastRecvTime = Strings.nullToEmpty(appUploadMonitor.getLastRecvTime());
        failureRate = appUploadMonitor.getFailureRate();
        loadsheetStatus = appUploadMonitor.isLoadsheetStatus();
        status = appUploadMonitor.getStatus();
    }

    public String getRemoteDateTime() {
        return remoteDateTime;
    }

    public void setRemoteDateTime(String remoteDateTime) {
        this.remoteDateTime = remoteDateTime;
    }

    public String getLocalDateTime() {
        return localDateTime;
    }

    public void setLocalDateTime(String localDateTime) {
        this.localDateTime = localDateTime;
    }

    public String getMinutesBetween() {
        return minutesBetween;
    }

    public void setMinutesBetween(String minutesBetween) {
        this.minutesBetween = minutesBetween;
    }

    public boolean isNtpStatus() {
        return ntpStatus;
    }

    public void setNtpStatus(boolean ntpStatus) {
        this.ntpStatus = ntpStatus;
    }

    public long getReceiveCount() {
        return receiveCount;
    }

    public void setReceiveCount(long receiveCount) {
        this.receiveCount = receiveCount;
    }

    public long getFailCount() {
        return failCount;
    }

    public void setFailCount(long failCount) {
        this.failCount = failCount;
    }

    public String getLastRecvTime() {
        return lastRecvTime;
    }

    public void setLastRecvTime(String lastRecvTime) {
        this.lastRecvTime = lastRecvTime;
    }

    public double getFailureRate() {
        return failureRate;
    }

    public void setFailureRate(double failureRate) {
        this.failureRate = failureRate;
    }

    public boolean isLoadsheetStatus() {
        return loadsheetStatus;
    }

    public void setLoadsheetStatus(boolean loadsheetStatus) {
        this.loadsheetStatus = loadsheetStatus;
    }

    public MonitorStatus getStatus() {
        return status;
    }

    public void setStatus(MonitorStatus status) {
        this.status = status;
    }

    @Override
    public AppUploadMonitor toEntity() {
        return null;
    }

    @Override
    public String toJSON() throws JsonProcessingException {
        return null;
    }
}
